home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / latex209 / contrib / misc / sines.tex < prev    next >
Text File  |  1991-10-05  |  1KB  |  48 lines

  1. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2. % macros to calculate sines from 90 to -90
  3. % Jim Walker,  Dept Mathematics,  University of South Carolina
  4. \newdimen\x
  5. \newdimen\y
  6. \newdimen\xsquare
  7. \newdimen\xfourth
  8. {% change char codes
  9.     \catcode`\p=12
  10.     \catcode`\t=12
  11.     \gdef\numonly#1pt{%
  12.         \def\xx{#1}%
  13.     }%
  14. }%
  15. \def\MULTyBYx{%
  16.     \expandafter\numonly\the\x
  17.     \edef\b{\y=\xx\y}%
  18.     \b
  19. }%
  20. \def\calcsin{% Find sin(\x) and put it in \y. Say \x is in degrees.
  21.     \x=0.0174533\x % Convert to radians.
  22.     \y=\x
  23.     \MULTyBYx
  24.     \xsquare=\y
  25.     \MULTyBYx
  26.     \MULTyBYx
  27.     \xfourth=\y
  28.     \y=1pt
  29.     \advance\y by -0.1666666\xsquare
  30.     \advance\y by 0.008333333\xfourth
  31.     \MULTyBYx
  32. }%
  33. % Example of use:
  34. %\x=23pt \calcsin \expandafter\numonly\the\y
  35. % Now \xx should contain the sine of 23 degrees.
  36. %\def\sine#1{\x=#1 \calcsin \expandafter\numonly\the\y \message{sine of
  37. %#1 is \xx}}
  38. %----------------------------------------------------------
  39. % given a box with width W and height H,  then its height after rotation by R
  40. % is W * sin(R) + H * cos(R),  and it extends W * cos(R) to the right
  41. % and H * sin(R) to the left
  42. % (arithmetic courtesy of Nico Poppelier)
  43. %
  44. \newdimen\xh\newdimen\xw\newdimen\xtemp\newdimen\xcos\newdimen\xsin
  45. \newdimen\xleft\newdimen\xright
  46. \def\MULTxtempBYxcos{\expandafter\numonly\the\xcos\edef\b{\xtemp=\xx\xtemp}\b}%
  47. \def\MULTxtempBYxsin{\expandafter\numonly\the\xsin\edef\b{\xtemp=\xx\xtemp}\b}%
  48.